package com.ytzl.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ytzl.demo.domain.BugDetail;
import com.ytzl.demo.service.BugDetailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/api")
public class DetailController {

    @Resource
    private BugDetailService service;

    @GetMapping("/getAll")
    @ResponseBody
    public List<BugDetail> getAll(@RequestParam Long projectId){
        if (projectId!=null){
            QueryWrapper wrapper=new QueryWrapper<>().eq("projectId",projectId);
            List<BugDetail> detail=service.list(wrapper);
            return detail;
        }else {
            List<BugDetail> detail=service.list();
            return detail;
        }
    }

    @PostMapping("/add")
    @ResponseBody
    public Object insert(@RequestBody BugDetail bugDetail){
        return service.save(bugDetail);
    }


}
